{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "edfb7077-f9e3-4b48-b621-6e54feeca7df",
   "metadata": {},
   "source": [
    "https://leetcode.com/problems/shortest-distance-to-a-character/\n",
    "\n",
    "\n",
    "Runtime: 4 ms, faster than 64.83% of C++ online submissions for Shortest Distance to a Character.\n",
    "Memory Usage: 6.8 MB, less than 30.46% of C++ online submissions for Shortest Distance to a Character.\n",
    "\n",
    "\n",
    "```cpp\n",
    "#include <bits/stdc++.h>\n",
    "\n",
    "using namespace std;\n",
    "\n",
    "class Solution {\n",
    "public:\n",
    "    vector<int> shortestToChar(string s, char c) {\n",
    "        //3:57\n",
    "        vector<int> target_list;\n",
    "        for (int i=0; i<s.size(); i++) {\n",
    "            if (s[i] == c) {\n",
    "                target_list.push_back(i);\n",
    "            }\n",
    "        }\n",
    "        vector<int> result;\n",
    "        for (int i=0; i<s.size(); i++) {\n",
    "            int min = INT32_MAX;\n",
    "            for (auto target : target_list) {\n",
    "                int value = abs(target-i);\n",
    "                if (value < min) {\n",
    "                    min = value;\n",
    "                }\n",
    "            }\n",
    "            result.push_back(min);\n",
    "        }\n",
    "        return result;\n",
    "        //4:02\n",
    "        //debug until 4:08\n",
    "    }\n",
    "};\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "75a1437a-a649-4e36-b025-ceffa33623df",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "C++17",
   "language": "C++17",
   "name": "xcpp17"
  },
  "language_info": {
   "codemirror_mode": "text/x-c++src",
   "file_extension": ".cpp",
   "mimetype": "text/x-c++src",
   "name": "c++",
   "version": "17"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
